package com.gulimall.member.controller.api;

import com.gulimall.common.api.member.req.MemberCreateReq;
import com.gulimall.common.api.member.service.MemberApi;
import com.gulimall.common.utils.R;
import com.gulimall.member.entity.MemberEntity;
import com.gulimall.member.service.MemberService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * Package: com.gulimall.member.controller.api
 * Description：API实现层
 * Author: huangjian
 * Date:  2020/7/9 16:12
 * Modified By:
 */
@RestController
public class MemberResource implements MemberApi {
    @Autowired
    private MemberService memberService;

    @Override
    public R createMember(MemberCreateReq req) {
        MemberEntity entity=new MemberEntity();
        BeanUtils.copyProperties(req,entity);
        memberService.save(entity);
        return R.ok();
    }

    @Override
    public R myList() {
        return R.ok().put("data",memberService.list());
    }
}
